package es.unileon.prg2.patterns.handler;

import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;

public class ShortNameTests {
	
	@Before
	public void setUp() throws Exception {
	}

	@Test(expected=MalformedHandlerException.class)
	public void testShortNameZero() throws Exception{
		new ShortName("");
	}
	
	@Test(expected=MalformedHandlerException.class)
	public void testShortNameMoreThanTwo() throws Exception{
		new ShortName("LEO");
	}
	
	@Test(expected=MalformedHandlerException.class)
	public void testShortNameOneWithOneNumber() throws Exception{
		new ShortName("2");
	}
	
	@Test(expected=MalformedHandlerException.class)
	public void testShortNameOneWithNumberAndLetter() throws Exception{
		new ShortName("2L");
	}
	
	@Test
	public void testShortNameCompareToOk() throws Exception{
		ShortName sn = new ShortName(new ShortName("LE"));
		assertEquals(sn.compareTo(new ShortName("LE")), 0);
	}
	
	@Test
	public void testShortNameCompareToNotOk() throws Exception{
		ShortName sn = new ShortName(new ShortName("LE"));
		assertEquals(sn.compareTo(new ShortName("LI")), -4);
	}
	
	@Test
	public void testShortNameToString() throws Exception{
		ShortName sn = new ShortName(new ShortName("BR"));
		assertEquals(sn.toString(), "BR");
	}

}
